package com.compomics.daubechiesfilter.example;

import com.compomics.daubechiesfilter.filter.DaubechiesFilter;
import com.compomics.util.experiment.massspectrometry.Spectrum;
import com.compomics.util.experiment.massspectrometry.SpectrumFactory;
import java.io.File;
import java.util.ArrayList;

/**
 * Hello world!
 *
 */
public class App {

    public static void main(String[] args) {
        try {
            SpectrumFactory fac = SpectrumFactory.getInstance();
            File spectrumFile = new File("src/test/resources/input_spectra.mgf");
            fac.addSpectra(spectrumFile);
            ArrayList<String> mgfTitles = fac.getMgfFileNames();
            ArrayList<String> spectrumTitles = fac.getSpectrumTitles(mgfTitles.get(0));
            Spectrum spectrum = fac.getSpectrum(mgfTitles.get(0), spectrumTitles.get(0));
            int mzCount = spectrum.getMzValuesAsArray().length;
            System.out.println("BEFORE : " + mzCount + " mz values");
            DaubechiesFilter filter = new DaubechiesFilter(spectrum);
            filter.filterSpectrum();
            mzCount = filter.getFilteredMzAsArray().length;
            double[] mz = filter.getFilteredMzAsArray();
            double[] intens = filter.getFilteredIntensitiesAsArray();
            int i = 0;
            System.out.println("AFTER : " + mzCount + " mz values");
            for (double aDouble : mz) {
                System.out.println(aDouble + "\t" + intens[i]);
                i++;
            }

        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
